home *** CD-ROM | disk | FTP | other *** search
/ Trading on the Edge / Trading On The Edge - CD-ROM Toolkit (Wayzata Technology)(2031)(1994).bin / pc / mac_file / vendor_d / neuralwa / nw2v50 / uio_tran.c < prev    next >
Text File  |  1993-08-23  |  7KB  |  218 lines

  1. /* uio_tran.c */
  2. /************************************************************************
  3.  * Copyright(C) 1987-1992 NeuralWare Inc                                *
  4.  * Penn Center West, IV-227, Pittsburgh, PA 15276                       *
  5.  * Telephone: (412) 787-8222    FAX: (412) 787-8220                     *
  6.  *                                                                      *
  7.  * All rights reserved.  No part of this program may be reproduced,     *
  8.  * stored in a retrieval system, or transmitted, in any form or by any  *
  9.  * means, electronic, mechanical, photocopying, recording or otherwise  *
  10.  * without the prior written permission of the copyright owner,         *
  11.  * NeuralWare, Inc.                                                     *
  12.  *                                                                      *
  13.  *                          PROPRIETARY NOTICE                          *
  14.  *                                                                      *
  15.  * This document is the property of NeuralWare, Inc. and contains       *
  16.  * trade-secrets and other proprietary information.  The information    *
  17.  * herein is reserved as proprietary to NeuralWare, and is not to be    *
  18.  * published, reproduced, copied, disclosed, used, or reverse           *
  19.  * engineered without the express written consent of a duly authorized  *
  20.  * representative of NeuralWare.                                        *
  21.  ************************************************************************
  22.  */
  23.  
  24. /*********************************************************************/
  25. /*                                                                   */
  26. /*    uio_tran.c - Transfer buffer utilities for both host and UIO   */
  27. /*                                                                   */
  28. /*    Author: John C. Fairman           August 31, 1990              */
  29. /*    Copyright 1990 by Neuralware Inc.                              */
  30. /*                                                                   */
  31. /*    $Author   :  $                                                 */
  32. /*    $Date     :  $                                                 */
  33. /*    $Source   :  $                                                 */
  34. /*    $Revision :  $                                                 */
  35. /*    $Log      :  $                                                 */
  36. /*                                                                   */
  37. /*********************************************************************/
  38.  
  39. #include "host.h"
  40.  
  41. #if defined(SUN)
  42. #include <sys/types.h>
  43. #endif
  44.  
  45. #ifdef MAC
  46. #include <StdDef.h>
  47. #endif
  48. #if defined(IBP) || defined(I860)
  49. #include <stddef.h>
  50. #endif
  51.  
  52. #ifdef __TURBOC__
  53. #include <mem.h>
  54. #endif
  55.  
  56. #define SKIP_COMPAT_DATA       1
  57. /* #include "userutl.h" */
  58. #include "uio_strc.h"
  59. #include "uio_tran.h"
  60. #include "uio_tran.pro"
  61.  
  62. #ifdef THINK_C
  63. #include "macuio.redef"
  64. #endif
  65.  
  66. #if defined(VMS)
  67. #include processes
  68. #include stdio
  69. #include descrip
  70. #include iodef
  71. #endif
  72.  
  73. /* FUNCTION */
  74. EXPORT UNINT get_data_size(count, data_type)
  75. NINT count;
  76. NINT data_type;
  77. {
  78.    UNINT size;
  79.    
  80.    size = ((data_type & 0x00F0) >> 4);
  81.    size *= count;
  82.    return(size);
  83. }
  84.  
  85. /* FUNCTION */
  86. EXPORT VOID Put_data_into_transfer_buffer(buffer, count, data_type)
  87. BUFFER_CHAR *buffer;
  88. NINT        count;
  89. NINT        data_type;
  90. {
  91.    UNINT size;
  92.    
  93.    size = get_data_size(count, data_type);
  94.    Data_transfer_ptr->data_descriptor.num_elements = (BUFFER_INT)count;
  95.    Data_transfer_ptr->data_descriptor.data_type = (BUFFER_INT)data_type;
  96.    if (size > SIZE_OF_UIO_BUFFER)
  97.       UIO_error_value = (NINT)OUTPUT_OVERFLOW;
  98.    else
  99.       if (buffer != (BUFFER_CHAR *)(Data_transfer_ptr->data_area.data))
  100.          MOVEMEM(Data_transfer_ptr->data_area.data, buffer, size);
  101. }
  102.  
  103. /* */
  104. /* FUNCTION */
  105. EXPORT VOID Get_data_from_transfer_buffer(buffer, count, data_type)
  106. BUFFER_CHAR *buffer;
  107. NINT        count;
  108. NINT        data_type;
  109. {
  110.    UNINT size;
  111.    
  112.    if (Data_transfer_ptr->data_descriptor.num_elements ==
  113.        (BUFFER_INT)count)
  114.       {
  115.          if (Data_transfer_ptr->data_descriptor.data_type ==
  116.              (BUFFER_INT)data_type)
  117.             {
  118.                size = get_data_size(count, data_type);
  119.                if (size > SIZE_OF_UIO_BUFFER)
  120.                   UIO_error_value = (NINT)INPUT_OVERFLOW;
  121.                else
  122.                   {
  123.                      if (buffer !=
  124.                          (BUFFER_CHAR *)(Data_transfer_ptr->data_area.data))
  125.                         {
  126.                            MOVEMEM(buffer, Data_transfer_ptr->data_area.data, size);
  127.                         }
  128.                   }
  129.                return;
  130.             }
  131.       }
  132.    UIO_error_value = (NINT)INPUT_CORRUPTION;
  133. }
  134.  
  135. /* */
  136.  
  137.  
  138. #if defined(VMS)
  139.  
  140. /*
  141.   VMS Mailbox read/write routines (rewrapper)
  142.   writing is to the channel (integer; -1 on fail) created by 'newmailbox'.
  143.   The routines getmailboxbytes/putmailboxbytes return the codes 0-error,
  144.   else number of bytes read (written). The lengths are not used by NW2,
  145.   as the buf sizes are implicit in the buffer contents.
  146.   */
  147.  
  148. /* VMS structure for mailboxes */
  149.  
  150. typedef struct
  151. {
  152.    short cond_value;
  153.    short count;
  154.    int info;
  155. }  io_statblk;
  156. io_statblk iosb;
  157.  
  158. short newmailbox(boxname)
  159. char *boxname;
  160. {
  161.    int stat;
  162.    short vmschan;
  163.    $DESCRIPTOR(mailbox, "hi");        /* dummy VMS system call descriptor */
  164.    mailbox.dsc$a_pointer = boxname;    /* add string (ptr) */
  165.    mailbox.dsc$w_length  = strlen(boxname);    /* and # of chars (not null) */
  166.    
  167.    /*  see also: VMS Programmer's Volume 4B: System Services; pg SYS-82 */
  168.    stat = SYS$CREMBX(    0,        /* zero for TEMPORARY (sub) process */
  169.                      &vmschan,    /* mandatory assigned channel */
  170.                      8192,        /* maxmsg */
  171.                      8192,        /* bufquo */
  172.                      0,        /* promsk */
  173.                      0,        /* acmode */
  174.                      &mailbox);    /* logname */
  175.    if ((stat & 1) != 1)
  176.       {
  177.          LIB$SIGNAL(stat);        /* error */
  178.          return(-1);
  179.       }
  180.    return(vmschan);
  181. }
  182.  
  183. getmailboxbytes(ch, bufaddr, len)
  184. char *bufaddr;
  185. int len;
  186. short ch;
  187. {
  188.    io_statblk iosb;
  189.    int stat;
  190.    stat = SYS$QIOW(2, ch, IO$_READVBLK, &iosb, 0, 0, bufaddr, len, 0,0,0,0);
  191.    if ((stat & 1) != 1) LIB$STOP(stat);
  192.    if ((iosb.cond_value & 1) != 1) LIB$STOP(iosb.cond_value);
  193.    return(iosb.count);
  194. }
  195.  
  196. putmailboxbytes(ch, bufaddr, len)
  197. char *bufaddr;
  198. int len;
  199. short ch;
  200. {
  201.    io_statblk iosb;
  202.    int stat;
  203.    /* write message to the mailbox channel 'vmschan' */
  204.    stat = SYS$QIOW(1, ch, IO$_WRITEVBLK, &iosb, 0, 0, bufaddr, len, 0,0,0,0);
  205.    if ((stat & 1) != 1) LIB$STOP(stat);
  206.    if ((iosb.cond_value & 1) != 1) LIB$STOP(iosb.cond_value);
  207.    return(len);                    /* OK */
  208. }
  209.  
  210. squeal(msg)
  211. char *msg;
  212. {
  213.    fprintf(stderr,"%s", msg);
  214.    fflush(stderr);
  215. }
  216.  
  217. #endif /* (VMS) */
  218.